import http from '@/utils/http-util'

let BASE_LOG_CONTENT = process.env.WEB_CONTEXT_PATH + 'log'
export function getLoginListApi(data = {}) {
  return http({
    url: BASE_LOG_CONTENT + '/login/list',
    method: 'post',
    data: http.bodyData({
      'page': data.page || 1,
      'pageSize': data.pageSize || 20,
      'sort': {
        'field': data.sortField,
        'rule': data.sortRule === undefined ? 1 : data.sortRule
      },
      'minCreateTime': data.minCreateTime || '',
      'maxCreateTime': data.maxCreateTime || '',
      'userName': data.userName || '',
      'ip': data.ip || ''
    })
  })
}

export function getLoginInfoApi(id = '0') {
  return http({
    url: BASE_LOG_CONTENT + '/login/' + id,
    method: 'get',
    params: http.queryParam()
  })
}

export function getRequestListApi(data = {}) {
  return http({
    url: BASE_LOG_CONTENT + '/request/list',
    method: 'post',
    data: http.bodyData({
      'page': data.page || 1,
      'pageSize': data.pageSize || 20,
      'sort': {
        'field': data.sortField,
        'rule': data.sortRule === undefined ? 1 : data.sortRule
      },
      'businessName': data.businessName || '',
      'ip': data.ip || '',
      'minCreateTime': data.minCreateTime || '',
      'maxCreateTime': data.maxCreateTime || '',
      'requestId': data.requestId || '',
      'requestUri': data.requestUri || '',
      'status': data.status || ''
    })
  })
}

export function getRequestInfoApi(id = '0') {
  return http({
    url: BASE_LOG_CONTENT + '/request/' + id,
    method: 'get',
    params: http.queryParam()
  })
}
